package com.aboverock.module.system.service;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.extension.service.IService;
import com.aboverock.module.system.domain.Resource;
import com.aboverock.module.system.domain.RestUrl;

/**
 * <p>
 * 服务类
 * </p>
 *
 * @author Rock Wang
 * @since 2018-04-10
 */
public interface ResourceService extends IService<Resource> {
    /**
     * 生成权限唯一标识.
     *
     * @param resource the resource
     * @return the string
     */
    public String generatePermissionStr(Resource resource);

    /**
     * 判断当前code在同一级资源中是否存在.
     *
     * @param resource the resource
     * @return true, if is duplicated code
     */
    public boolean isDuplicatedCode(Resource resource);

    /**
     * 更新资源信息.
     *
     * @param resource the resource
     * @param oldResource the old resource
     * @return true, if successful
     * @throws SQLException the SQL exception
     */
    public boolean update(Resource resource, Resource oldResource) throws SQLException;

    /**
     * 根据登陆名查询该用户所拥有的资源.
     *
     * @param loginName the login name
     * @return the resources by login name
     */
    public List<Resource> getResourcesByLoginName(String loginName);

    /**
     * 根据id删除资源及其子资源，同时删除角色-资源映射表中数据.
     *
     * @param resourceId the resource id
     * @return true, if successful
     * @throws SQLException the SQL exception
     */
    public boolean deleteById(String resourceId) throws SQLException;

    /**
     * 交换两个资源的排序.
     *
     * @param resource1 the resource 1
     * @param resource2 the resource 2
     * @return true, if successful
     * @throws SQLException the SQL exception
     */
    public boolean exchangeOrderNo(Resource resource1, Resource resource2) throws SQLException;

    /**
     * shiro按指定顺序加载所有资源.
     *
     * @return the list
     */
    public List<Resource> getResources();

    /**
     * 获取项目中接口的url.
     *
     * @return the urls
     */
    public Map<String, List<RestUrl>> getUrls();

}
